import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'
import Layout2 from '@/layout/layout'

export const constantRoutes = [
  {
    path: '/login',
    name: '/login',
    component: () => import('@/views/login'),
    hidden: true,
    meta: { hidden: true }
  },
  {
    name: '/',
    path: '/',
    redirect: '/home',
    component: Layout,
    children: [
      {
        name: '/home',
        path: '/home',
        title: '首页',
        meta: { title: '首页', icon: require('@/assets/首页.png') },
        component: () => import('@/views/home/home')
      },
      {
        name: '/project',
        path: '/project',
        meta: { title: '项目管理', icon: require('@/assets/项目管理.png') },
        component: Layout2,
        children: [
          {
            name: '/project/project1',
            path: '/project/project1',
            meta: { title: '重点项目' },
            component: () => import('@/views/project/project1')
          },
          {
            name: '/project/project2',
            path: '/project/project2',
            meta: { title: '3.0项目' },
            component: () => import('@/views/project/project2')
          },
          {
            name: '/project/event',
            path: '/project/event',
            meta: { title: '基础事项库' },
            component: () => import('@/views/project/event')
          },
          {
            name: '/project/config-edit',
            path: '/project/config-edit',
            hidden: true,
            meta: { title: '项目流程配置编辑' },
            component: () => import('@/views/project/config/add')
          },
          {
            name: '/project/template',
            path: '/project/template',
            meta: { title: '项目默认流程管理' },
            component: () => import('@/views/project/template')
          },
          {
            name: '/project/template-config',
            path: '/project/template-config',
            hidden: true,
            meta: { title: '项目默认流程管理' },
            component: () => import('@/views/project/template/canvas/config')
          },
          {
            name: '/project/assets',
            path: '/project/assets',
            meta: { title: '国有资产不动产列表' },
            component: () => import('@/views/project/assets')
          },
          {
            name: '/project/log',
            path: '/project/log',
            meta: { title: '工作记录' },
            component: () => import('@/views/project/log')
          }
        ]
      },
      {
        name: '/assistant',
        path: '/assistant',
        meta: { title: '精准帮办管理', icon: require('@/assets/精准帮办管理.png') },
        component: Layout2,
        children: [
          {
            name: '/assistant/accurate',
            path: '/assistant/accurate',
            meta: { title: '精准帮办列表' },
            component: () => import('@/views/assistant/accurates')
          },
          {
            name: '/assistant/elegant',
            path: '/assistant/elegant',
            meta: { title: '帮办风采管理' },
            component: () => import('@/views/assistant/elegant')
          },
          {
            name: '/assistant/alarm',
            path: '/assistant/alarm',
            meta: { title: '预警管理' },
            component: () => import('@/views/assistant/alarm')
          },
          {
            name: '/assistant/audit',
            path: '/assistant/audit',
            meta: { title: '会商会审' },
            component: () => import('@/views/assistant/audit')
          }
        ]
      },
      {
        name: '/rescue',
        path: '/rescue',
        meta: { title: '纾困解难管理', icon: require('@/assets/纾困解难管理.png') },
        component: Layout2,
        children: [
          {
            name: '/rescue/policy',
            path: '/rescue/accurate',
            meta: { title: '政策推荐管理' },
            component: () => import('@/views/rescue/policy')
          },
          {
            name: '/rescue/qs',
            path: '/rescue/qs',
            meta: { title: '用户疑问列表' },
            component: () => import('@/views/rescue/user-qs')
          }
        ]
      },
      {
        name: '/approval',
        path: '/approval',
        meta: { title: '报批指导管理', icon: require('@/assets/报批指导管理.png') },
        component: () => import('@/views/approval')
      },
      {
        name: '/note',
        path: '/note',
        meta: { title: '投资项目办件信息', icon: require('@/assets/事项管理.png') },
        component: () => import('@/views/note')
      },
      {
        name: '/performance',
        path: '/performance',
        meta: { title: '绩效考核管理', icon: require('@/assets/绩效考核管理.png') },
        component: () => import('@/views/performance')
      },
      {
        name: '/report',
        path: '/report',
        meta: { title: '智能报表管理', icon: require('@/assets/智能报表管理.png') },
        component: () => import('@/views/report')
      },
      {
        name: '/intermediary',
        path: '/intermediary',
        meta: { title: '掌上中介管理', icon: require('@/assets/掌上中介管理.png') },
        component: Layout2,
        children: [
          {
            name: '/intermediary/base-info',
            path: '/intermediary/base-info',
            meta: { title: '中介信息' },
            component: () => import('@/views/intermediary/base-info/base-info')
          },
          {
            name: '/intermediary/bus-info',
            path: '/intermediary/bus-info',
            meta: { title: '比选业务信息' },
            component: () => import('@/views/intermediary/bus-info/bus-info')
          },
          {
            name: '/intermediary/serve-bus-info',
            path: '/intermediary/serve-bus-info',
            meta: { title: '中介服务领域比选项目信息' },
            component: () => import('@/views/intermediary/serve-bus-info/bus-info')
          }
          // {
          //   name: '/intermediary/ap',
          //   path: '/intermediary/ap',
          //   meta: { title: '评价管理' },
          //   component: () => import('@/views/intermediary/ap/ap')
          // }
        ]
      },
      {
        name: '/system',
        path: '/system',
        meta: { title: '系统设置', icon: require('@/assets/智能报表管理.png') },
        component: Layout2,
        children: [
          {
            name: '/system/user-info',
            path: '/system/user-info',
            hidden: true,
            meta: { title: '用户管理' },
            component: () => import('@/views/user-info')
          },
          {
            name: '/system/user',
            path: '/system/user',
            meta: { title: '用户管理' },
            component: () => import('@/views/system/user/user')
          },
          {
            name: '/system/admin',
            path: '/system/admin',
            meta: { title: '管理人员' },
            component: () => import('@/views/system/admin/admin')
          },
          {
            name: '/system/banner',
            path: '/system/banner',
            meta: { title: 'Banner图管理' },
            component: () => import('@/views/system/banner/banner')
          },
          {
            name: '/system/tag',
            path: '/system/tag',
            meta: { title: '标签管理' },
            component: () => import('@/views/system/tag/tag')
          }
        ]
      }
    ]
  }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
